package com.smasher.widget.util;


import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;

import androidx.annotation.RequiresApi;

public class NavigationSystemPage {

    private NavigationSystemPage() {

    }

    public static NavigationSystemPage getInstance() {
        return Holder.INSTANCE;
    }


    public static class Holder {
        private static final NavigationSystemPage INSTANCE = new NavigationSystemPage();
    }

    /**
     * 跳转到设备信息页面
     *
     * @param context context
     */
    public void navigationToDeviceInfoPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到显示设置页面
     *
     * @param context context
     */
    public void navigationToSettingPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到Wi-Fi设置页面
     *
     * @param context context
     */
    public void navigationToWiFiPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到声音设置页面
     *
     * @param context context
     */
    public void navigationToSoundPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到应用程序设置页面
     *
     * @param context context
     */
    public void navigationToApplicationPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到安全设置页面
     *
     * @param context context
     */
    public void navigationToSecurityPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到定位服务设置页面
     *
     * @param context context
     */
    public void navigationToLocationPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到日期和时间设置页面
     *
     * @param context context
     */
    public void navigationToDatePage(Context context) {
        Intent intent = new Intent(Settings.ACTION_DATE_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到蓝牙设置页面
     *
     * @param context context
     */
    public void navigationToBluetoothPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到语言和输入法设置页面
     *
     * @param context context
     */
    public void navigationToInputMethodPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到备份和重置设置页面
     *
     * @param context context
     */
    public void navigationToPrivacyPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_PRIVACY_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到开发者选项页面
     *
     * @param context context
     */
    public void navigationToDevelopmentPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
        context.startActivity(intent);
    }


    //=========================================================================


    /**
     * 跳转到特定应用信息页面
     *
     * @param context context
     */
    public void navigationToApplicationDetailPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", context.getPackageName(), null);
        intent.setData(uri);
        context.startActivity(intent);
    }


    /**
     * 跳转到通知设置页面（Android 8.0及以上）
     *
     * @param context context
     */
    @RequiresApi(api = Build.VERSION_CODES.O)
    public void navigationToApplicationNotificationPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
                .putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
        context.startActivity(intent);
    }

    /**
     * 跳转到电池优化设置页面
     *
     * @param context context
     */
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
    public void navigationToBatteryOptimizationPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS);
        context.startActivity(intent);
    }

    //=======================================================================

    /**
     * 跳转到语言和地区设置页面
     *
     * @param context context
     */
    public void navigationToLocalePage(Context context) {
        Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);
        context.startActivity(intent);
    }


    /**
     * 跳转到存储设置页面
     *
     * @param context context
     */
    public void navigationToInternalStoragePage(Context context) {
        Intent intent = new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到辅助功能设置页面
     *
     * @param context context
     */
    public void navigationToAccessibilityPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到数据用量设置页面
     *
     * @param context context
     */
    @RequiresApi(api = Build.VERSION_CODES.P)
    public void navigationToDataUsagePage(Context context) {
        Intent intent = new Intent(Settings.ACTION_DATA_USAGE_SETTINGS);
        context.startActivity(intent);
    }


    //======================================================

    /**
     * 跳转到飞行模式设置页面
     *
     * @param context context
     */
    public void navigationToAirPlaneModePage(Context context) {
        Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到NFC设置页面
     *
     * @param context context
     */
    public void navigationToNFCPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到网络运营商设置页面
     *
     * @param context context
     */
    public void navigationToNetworkOperatorPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
        context.startActivity(intent);
    }

    /**
     * 跳转到同步设置页面
     *
     * @param context context
     */
    public void navigationToSyncPage(Context context) {
        Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
        context.startActivity(intent);
    }


}
